// 编写一段Scala代码实现判断一个字符串是否为回文字。123321 12321
object Test {
  def main(args: Array[String]) {
    var str1 = new String("qweewq")
    var str2 = "345423"
    var str3 = "tyuyt"
    println( "Is it a reply text?:" + isPalindrome(str1));
    println( "Is it a reply text?:" + isPalindrome(str2));
    println( "Is it a reply text?:" + isPalindrome(str3));
  }
  def isPalindrome(str:String): Boolean = {
    for ( i <- 0 to str.length-1) {
      if (str.charAt(i) != str.charAt(str.length-i-1)){
        return false
      }
    }
    return true
  }
}


// def isPalindrome(str: String): Boolean = {
//   val len = str.length
//   val halfLen = len / 2
//   for (i <- 0 until halfLen) {
//     if (str(i) != str(len - i - 1)) {
//       return false
//     }
//   }
//   true
// }

// // 测试样例
// println(isPalindrome("racecar")) // true
// println(isPalindrome("hello")) // false
